﻿@using FujiyBlog.Core.DomainObjects
@using FujiyBlog.Core.Extensions
@using FujiyBlog.Web.Controllers
@using FujiyBlog.Web.Models
@using Microsoft.Web.Helpers
@model PostComment

@using (Ajax.BeginForm(MVC.Comment.ActionNames.DoComment, MVC.Comment.Name, new { id = Model.Post.Id }, new AjaxOptions { OnSuccess = "fujiyBlog.comments.addCommentSuccess(arguments[0]);", OnFailure = "fujiyBlog.comments.addCommentFailure" }, new { id = "add-comment-form" }))
{
    <div class="commentForm">
        @Html.Hidden("ParentCommentId", Model.ParentComment != null ? Model.ParentComment.Id.ToString() : string.Empty)
        <p class="addcomment">
            @Resources.Labels.AddComment</p><div style="display:none" id="cancel-replying"><a href="javascript:void(0)" onclick="javascript:fujiyBlog.comments.cancelReplyComment();">@Resources.Labels.CancelReply</a></div>
        @if (!Request.IsAuthenticated)
        {
            <div id="comment-user-data">
                
                <div style="display: none;" id="openid_choice">
                    <p>Please select your account provider and <a href="javascript:void(0);" id="open-openid-login">click here to login with your OpenID</a>:</p>
                    <div id="openid_btns"></div>
                </div> 
                <div id="openid_input_area">
                </div>
                <input id="openid_identifier" name="openid_identifier" type="hidden" />
                
                <div><p><strong>Or enter your details below</strong></p></div>

                @Html.LabelFor(x => x.AuthorName)
                @Html.TextBoxFor(x => x.AuthorName, new {data_val = "true", data_val_required = "The Name field is required."})
                @Html.ValidationMessageFor(x => x.AuthorName)

                @Html.LabelFor(x => x.AuthorEmail)
                @Html.EditorFor(x => x.AuthorEmail)
                @Html.ValidationMessageFor(x => x.AuthorEmail)

                @Html.LabelFor(x => x.AuthorWebsite)
                @Html.EditorFor(x => x.AuthorWebsite)
                @Html.ValidationMessageFor(x => x.AuthorWebsite)
            </div>
            
            <div id="logout-social-id" style="display: none;">
                @Ajax.ActionLink("Logout", MVC.Social.Logout(), new AjaxOptions { OnSuccess = "fujiyBlog.socialId.callbackLogout" })
            </div>
        }
        <div>
            @Html.TextAreaFor(x => x.Comment)
            @Html.ValidationMessageFor(x => x.Comment)
        </div>
        @if (Settings.SettingRepository.ReCaptchaEnabled && !User.IsInRole(Role.ModerateComments))
        {
            <div class="commentCaptcha">
                @ReCaptcha.GetHtml(Settings.SettingRepository.ReCaptchaPublicKey)
            </div>
        }
        <input type="submit" value="@Resources.Labels.SaveComment" /><div id="comment-sucess" style="display: none;"><strong>@Resources.Labels.CommentSent</strong></div>
    </div>
}
